package com.lordjoe.collectiveintelligence.data;

import java.util.*;

/**
 * com.lordjoe.collectiveintelligence.data.MeasurementSet
 *
 * @author Steve Lewis
 * @date May 12, 2009
 */
public class MeasurementSet<T> implements IMeasurementSet<T>
{
    public static MeasurementSet[] EMPTY_ARRAY = {};
    public static Class THIS_CLASS = MeasurementSet.class;

    private final IMeasurementType<T> m_Type;
    private final List<IMeasurement<T>> m_Items = new ArrayList<IMeasurement<T>>();

    public MeasurementSet(IMeasurementType<T> pType)
    {
        m_Type = pType;
    }
    public MeasurementSet(IMeasurementType<T> pType,IMeasurement<T>[] items)
    {
        m_Type = pType;
        for (int i = 0; i < items.length; i++) {
            IMeasurement<T> item = items[i];
            m_Items.add(item);
        }
    }

    public void addMeasurement(IMeasurement<T> s)
    {
        m_Items.add(s);
    }

    public IMeasurementType<T> getType()
    {
        return m_Type;
    }

    public Class<T> getDataType()
    {
        return getType().getType();
    }

    public IMeasurement<T>[] getItems()
    {
       return  m_Items.toArray(IMeasurement.EMPTY_ARRAY);
    }



}
